const mysql = require('mysql');

const pool = mysql.createPool({
    host: 'localhost',
    user: 'root',
    password: 'root',
    connectionLimit: 10,
    database: 'kkk'
})

module.exports = (sql, value = []) => {
    return new Promise((resolve, reject) => {
        pool.getConnection((err, connection) => {
            if (err) reject(err)
            connection.query(sql, value, (err, result) => {
                connection.release();
                if (err) reject(err)
                resolve(result)
            })
        })
    })
}